<?php
/**
 * User: Matrix
 * Date: 27/10/12
 */
class Pages extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model('categoria_model');
        $this->load->model('comun_model');
    }

    public function view($page = 'home')
    {
        if (!file_exists('application/views/pages/web/v_' . $page . '.php')) {
            show_404();
        }
        $data=array();
        $seleccion=array();

        $seleccion["home"]="";
        $seleccion["servicio"]="";
        $seleccion["quienes_somos"]="";
        $seleccion["ubicacion"]="";
        $seleccion["contacto"]="";
        $seleccion["menu"]="";
        $seleccion["entregados"]="";
        $seleccion["proyectos"]="";
        $seleccion[$page]="current";

        $categorias = $this->categoria_model->get_categorias();

        $result=array();
        foreach ($categorias as $categoria):
            $subcategorias=$this->categoria_model->get_categorias($categoria["codigo"]);
            $categoria["detalle"]=$subcategorias;
            $categoria["totalItems"]=count($subcategorias);
            $result[]=$categoria;
        endforeach;

        $menu=array();

        $menu['categorias'] = $result;

        if ($page == 'home') {
            $this->load->view('pages/web/templates/head_home');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'empresa') {
            $this->load->view('pages/web/templates/head_web2');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'cotizar') {
            $this->load->view('pages/web/templates/head_web');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'servicios') {
            $this->load->view('pages/web/templates/head_web');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'tips_interes') {
            $registros = $this->comun_model->get_tips_interes();
            $data['registros'] = $registros;
            $this->load->view('pages/web/templates/head_web');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'sabias_que') {
            $registros = $this->comun_model->get_sabiasque();
            $data['registros'] = $registros;
            $this->load->view('pages/web/templates/head_web');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'novedades') {
            $registros = $this->comun_model->get_novedades();
            $data['registros'] = $registros;
            $this->load->view('pages/web/templates/head_web');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }else if ($page == 'soporte') {
            $this->load->view('pages/web/templates/head_web');
            $this->load->view('pages/web/templates/layout_top',$menu);
            $this->load->view('pages/web/v_' . $page,$data);
            $this->load->view('pages/web/templates/layout_down');
        }

    }
}

?>
